package cn.edu.zafu.bigdata.x.yaojy;

public class DivideDemo {
    public static int divide(int a, int b){
        if (b == 0){
            throw new ArithmeticException("分母不能为0！");
        }
        return a /b;
    }

    public static void main(String[] args) {
        int a = 10;
        int b = 0;

        try{
            int result = divide(a,b);
            System.out.println("除法结果: " + result);
        } catch (ArithmeticException e) {
            System.out.println("错误信息: " + e.getMessage());
        }

        b=2;
        try{
            int result = divide(a,b);
            System.out.println("除法结果: " + result);
        } catch (ArithmeticException e) {
            System.out.println("错误信息: " + e.getMessage());
        }
    }


}
